$(document).ready(function()
{
		/*control the drawers*/
		$('.middle-container ul li').hoverIntent({
				over:function(){var index= $(this).index();$(this).addClass('active');$(this).siblings().removeClass('active');var d = $(".drawer:eq(" +index+ ")");d.fadeIn(200);d.siblings(".drawer").fadeOut(300);}, 
				timeout: 300, 
				out:function(){}
			});
		$('.wordmark,.banner').hover(function(){$(".middle-container ul li").removeClass('active');$(".drawer").fadeOut(450);},function(){});
		
		/*contentpage subnav slide*/
		$(".secondary-ul").parent().prepend("<div class='isub'>»</div>");
		$(".isub").click(function(){$(this).siblings(".secondary-ul").slideToggle("fast");});
		$(".subnav-box a").click(function(){$(this).siblings(".secondary-ul").slideToggle("fast");});
		$(".secondary-ul").find(".on").parents(".secondary-ul").css("display","block");
		/*contentpage upper 9 hrefs*/
		$(".middle-container a").each(
		function(){
			var x = $(this).parent().attr("id");
			switch(x)
			{ 
				case "navoverview": $(this).attr("href","overview/introduction.html");
				break;
				case "navcourse": $(this).attr("href","course/coursequery.html");
				break;
				case "navdevelop": $(this).attr("href","develop/innovation.html");;
				break;
				case "navteacher": $(this).attr("href","teacher/brief.html");
				break;
				case "navenroll": $(this).attr("href","enroll/information.html");
				break;
				case "navnewscenter": $(this).attr("href","newscenter/announce.html");
				break;
				case "navgreatcourse": $(this).attr("href","greatcourse/greatcourse.html");
				break;
				case "navteachtrack": $(this).attr("href","teachtrack/globalquery.html");
				break;
				case "navquestion": $(this).attr("href","question/questionanswered.html");
				break;
				default: ;
			}
		});
		/*indexpage teacher slide*/
		var length = $(".briefintro").length;
		width  = length*270;
		length1 = ((length-5)>=0)?(length-5):length;
		width1 = length1*270;
		$(".slideshow ul").css("width",width + "px");
		$("#slideright").click(function(){slideright();});
		$("#slideleft").click(function(){slideleft();});
		/*logo the href to index*/
		$(".logo").attr("href","index.html");
		/*gototop*/
		gotoTop();
});

/*showtimenow div*/
function getTime(myDate) 
{
var y=myDate.getYear()+1900; //获取年

var m=myDate.getMonth()+1; //获取月
m=m>9?m:"0"+m; //如果月份小于10,则在前面加0补充为两位数字

var d=myDate.getDate(); //获取日
d=d>9?d:"0"+d; //如果天数小于10,则在前面加0补充为两位数字

var h=myDate.getHours(); //获取小时
h=h>9?h:"0"+h; //如果小时数字小于10,则在前面加0补充为两位数字

var M=myDate.getMinutes(); //获取分
M=M>9?M:"0"+M; //如果分钟小于10,则在前面加0补充为两位数字

var s=myDate.getSeconds(); //获取秒
s=s>9?s:"0"+s; //如果秒数小于10,则在前面加0补充为两位数字

var NowTime=y+"年"+m+"月"+d+"日"+" "+h+"："+M+"："+s; //串联字符串用于输入
return NowTime;
}
function tick()
{
	var timenow;
	timenow = new Date();
	document.getElementById("timeDiv").innerHTML = getTime(timenow);
	window.setTimeout("tick()", 500);/*改成500呢？显示不会影响，甚至更准*/
}



function gotoTop(/*min_height*/)
{
	var totop = "<a class='totop'><i></i><span>顶部</span></a>";
	$("body").append(totop);
    $(".totop").click(//定义返回顶部点击向上滚动的动画
        function(){$('html,body').animate({scrollTop:0},200);
    })/*.hover(//为返回顶部增加鼠标进入的反馈效果，用添加删除css类实现
        function(){$(this).addClass("hover");},
        function(){$(this).removeClass("hover");
    })*/;
    
/*    //获取页面出现top按钮时的最小高度，无传入值则默认为600像素
    min_height?min_height = min_height : min_height = 600;
*/
    
    //为窗口的scroll事件绑定处理函数
    $(window).scroll(function(){
        //获取窗口的滚动条的垂直位置
        var s = $(window).scrollTop();
        //当窗口的滚动条的垂直位置大于页面的最小高度时，让返回顶部元素渐现，否则渐隐
        if( s > 600){
            $(".totop").fadeIn(100);
        }else{
            $(".totop").fadeOut(200);
        };
    });
};
/*试着做个重复数据校验工具*/
function checkduplication(m)
{
	var y = m.table;
	var z = m.field;
	var msg = m.msg;
	$("#"+m.cid).blur(function(){
		var x = $("#"+m.cid).val();
		var x1 = m.nvl;
		if(x != x1)
			{
				$.ajax({
					url:"user/checkduplication.html",
					type:"post",
					dataType:"text",
					data:{cid:x,table:y,field:z},
					success:function(data){
							if(data == 1)
								{
									$("#"+m.aid+"").css("color","red");
									$("#"+m.aid+"").html(msg);
									$("#"+m.cid).css("border","1px solid red");
									$("#"+m.cid).focus();
								}
							else
								{
									$("#"+m.aid+"").html("");
									$("#"+m.cid).css("border","");
								}
							},
					error:function(){
					}
				});
			}
		else
			{
				$("#"+m.aid+"").html("");
				$("#"+m.cid).css("border","");
			}
	});
}
var ml = -270;
//教师栏左右滑动的实际函数
function slideleft()
{
	//var ml = $(".slideshow ul").css("margin-left").replace("px","");
	if(ml>-270)
	{
		ml=-width1;
		$(".slideshow ul").css("margin-left",ml+"px");
	}
	ml= parseInt(ml)+270;
	$(".slideshow ul").animate({'margin-left':ml},{speed:"normal",queue:false});
}
function slideright()
{
	//var ml = $(".slideshow ul").css("margin-left").replace("px","");
	if(ml<-width1)
	{
		ml=-270;
		$(".slideshow ul").css("margin-left","-270px");
	}
	ml= parseInt(ml)-270;
	$(".slideshow ul").animate({'margin-left':ml},{speed:"normal",queue:false});
}

//favicon写入页面
document.write("<link rel='shortcut icon' type='image/x-icon' href='http://localhost:8080/bupteist/favicon.ico'/>");